package com.fujiyang.controller;

import com.fujiyang.dto.LoginDTO;
import com.fujiyang.service.UserService;
import com.fujiyang.result.Result;
import com.fujiyang.vo.UserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/admin/user")
@Api(tags = "用户登录接口")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户登录
     *
     * @param loginDTO 登录信息
     * @return 登录结果
     */
    @PostMapping("/login")
    @ApiOperation(value = "用户登录")
    public Result<UserVO> login(@RequestBody LoginDTO loginDTO) {
        log.info("用户登录: {}", loginDTO);

        // 调用服务层进行用户登录验证
        UserVO userVO = userService.login(loginDTO);

        return Result.success(userVO);
    }
}
